<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>

	<title>我的送检单</title>
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta name="viewport" content="width=device-width, initial-scale=1" />
	<link rel="icon" href="favicon.ico" />

	<!-- table导出成excel 不用-->
	<!-- <script src="static/manage-sys/js/table2excel.js"></script> -->

	<!--[if lt IE 9]>
	<script src="js/bootstrap/html5shiv.min.js"></script>
	<script src="js/bootstrap/respond.min.js"></script>
	<![endif]-->
	<!--页面加载进度条-->


	<link href="css/pace/dataurl.css" rel="stylesheet" />
	<link rel="stylesheet" type="text/css" href="add-sample/easyui/themes/ui-cupertino/easyui.css" />
	<link rel="stylesheet" type="text/css" href="add-sample/easyui/themes/icon.css" />
	<link rel="stylesheet" type="text/css" href="add-sample/css/icon.css" />
	<link rel="stylesheet" type="text/css" href="add-sample/css/uims.css" />
	<link rel="stylesheet" type="text/css" href="add-sample/css/temp.css" />

	<link href="css/bootstrap.min.css" rel="stylesheet" />
	<link href="css/font-awesome.min.css" rel="stylesheet" />
	<link href="css/default.css" rel="stylesheet" type="text/css" />

	<script src="js/jquery.min.js"></script>
	<script type="text/javascript" src="add-sample/easyui/jquery.min.js"></script>
	<script src="js/jquery.hammer/hammer.min.js"></script>
	<script src="js/jquery.hammer/jquery.hammer.js"></script>

	<script type="text/javascript" src="add-sample/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="add-sample/easyui/locale/easyui-lang-zh_CN.js"></script>


	<script src="js/pace/pace.min.js" type="text/javascript"></script>
	<script src="js/jquery.scrolltopcontrol/scrolltopcontrol.js" type="text/javascript"></script>
	<script src="js/jquery.extend.js" type="text/javascript"></script>
	<script src="js/default.js" type="text/javascript"></script>
	<script src="js/bootstrap/bootstrap.min.js" type="text/javascript"></script>
	<script src="js/bootstrap/bootstrap-table.min.js" type="text/javascript"></script>
	<script src="js/bootstrap/bootstrap-table-zh-CN.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="add-sample/js/dataGridCellTip.js"></script>
	<script type="text/javascript" src="add-sample/js/validate.js"></script>
	<script type="text/javascript" src="add-sample/js/json2.js"></script>
	<script type="text/javascript" src="add-sample/js/sampleCommon.js"></script>
	<script type="text/javascript" src="add-sample/js/template.js"></script>
	<!--<script type="text/javascript" src="add-sample/js/deaf.js"></script>-->
	<!-- 下拉菜单 -->
	<link href="./css/bootstrap-select/bootstrap-select.min.css" rel="stylesheet" />
	<script src="./js/bootstrap-select/bootstrap-select.min.js"></script>
	<script src="./js/bootstrap-select/i18n/defaults-zh_CN.min.js"></script>
	<script src="./js/bootstrap-select/bootstrap-select-custom.js"></script>

	<script src="js/fileServer.js"></script>
	<!-- artTemplate 模板引擎 -->
	<script src="js/template-web.js" type="text/javascript"></script>
	<!-- 送检单导出操作-->
	<script src="js/exportTable.js"></script>

    <style>

		.table-wrapper panel-noscroll .panel datagrid easyui-fluid{height:100%;width:100%}
		.coupon-box {
			height: 120px;
			text-align: center;
			line-height: 120px;
			border: 1px dashed #2e85b8;
			font-size: 24px;
			color: #cecece;
			margin-top: 30px;
			cursor: pointer;
			background: #fff;
		}

		.coupon-item {
			width: 80%;
			box-shadow: 2px 2px 5px #f2f2f2, -2px -2px 5px #f2f2f2;
			border-bottom: 1px solid #eee;
			display: flex;
			margin: 10px auto;
			flex-direction: row;
		}

		.coupon-item .btn {
			display: block;
			margin: 10px;
			width: 60px;
			padding: 0;
			height: 28px;
			line-height: 28px;
			text-align: center;
			background: #45b4f5;
			color: #fff;
			/* outline: none; */
			border-color: transparent;
		}

		.coupon-item .content-wrapper {
			flex: 1;
			padding: 10px;
		}

		.coupon-item .content-wrapper .name {
			font-size: 14px;
			font-weight: 400;
			color: rgba(0, 0, 0, 0.85);
		}

		.coupon-item .content-wrapper .desc {
			font-size: 12px;
			margin-top: 4px;
			color: rgba(0, 0, 0, 0.55);
		}

		.search-box input {
			display: inline-block;
			flex: 1;
			height: 33px;
			line-height: 33px;
			padding-left: 6px;
			/* border-color: transparent; */
			outline: none;
			box-shadow: none;
			/* border: 0; */
			border: 1px solid #7bcdf8;
		}

		.search-box button {
			width: 80px;
			background: #7bcdf8;
			outline: none;
			border: 1px solid #7bcdf8;
			color: #fff;
		}

		.empty-coupon {
			text-align: center;
			line-height: 42px;
			height: 42px;
			font-size: 18px;
			color: rgba(0, 0, 0, 0.45);
		}

		.search-params {
			border-bottom: 1px solid #dedede;
			margin: 20px 16px;
		}

		.panel-body {
			position: relative;
			border-left: 0 !important;
			padding: 15px !important;
			overflow: initial;
		}

		.search-row {
			display: flex;
			flex-direction: row;
		}

		.search-item {
			flex: 1;
			display: flex;
			flex-direction: row;
			margin-left: 30px;
		}

		.search-item:first-child {
			margin-left: 0;
		}

		.search-item>label {
			display: inline-block;
			min-width: 80px;
			letter-spacing: 2px;
			text-align: center;
			height: 33px;
			line-height: 33px;
		}

		.search-item>.value {
			display: inline-block;
			flex: 1;
			height: 33px;
			line-height: 33px;
		}

		div.btn-operate {
			margin: 20px 16px;
			text-align: center;
		}

		div.btn-operate>button {
			display: inline-block;
			width: 120px;
			margin: 6px;
			margin-left: 30px;
		}

		div.btn-operate>button:first-child {
			margin-left: 0;
		}

		input {
			outline: none !important;
		}


		.params-warpper {
			display: flex;
			flex-direction: row;
			padding-right: 200px;
		}

		#search-btn {
			position: absolute;
			right: 88px;
			top: 50%;
			transform: translateY(-50%);
			width: 90px;
		}

		#reset-btn {
			position: absolute;
			right: 16px;
			top: 50%;
			transform: translateY(-50%);
			width: 50px;
		}

		.params-warpper .params-item {
			flex: 1;
			display: flex;
			flex-direction: row;
			margin-top: 10px;
		}

		.params-warpper .params-item label {
			display: inline-block;
			min-width: 120px;
			line-height: 34px;
			text-align: right;
			letter-spacing: 2px;
		}

		.params-warpper .params-item .value {
			flex: 1;
		}

		.add-sample {
			margin: 10px;
		}

		.maincontent {
			height:800px;
			display: flex;
			flex-direction: column;
			overflow:auto;
		}

		.table-wrapper {
			flex: 1;
			display: flex;
			flex-direction: column;
			overflow-y: scroll;
		}

		.maincontent {
			min-width: 1000px !important;
			overflow: hidden !important;
			overflow-x: scroll !important;
		}

		.split {
			line-height: 33px;
			height: 33px;
			display: inline-block;
			width: 20px;
			text-align: center;
		}

		input[type=checkbox],
		input[type=radio] {
			margin: auto;
		}

		.datagrid-row-selected {
			background: #fff;
		}
	</style>
</head>

<body  style="width:100%;height:100%;" >

<div class="maincontent">

	<!--我是主要内容-->
	<!--我是主要内容-->

	<div class="panel panel-default box-params">
		<div class="panel-heading">
			查询条件
		</div>
		<div class="panel-body form-group">
			<div class="params-warpper">
				<div class="params-item">
					<label class="control-label">姓名：</label>
					<input type="text" placeholder="请输入姓名" class="form-control value" id="sampleName" />
				</div>
				<div class="params-item">
					<label class="control-label">联系电话：</label>
					<input type="text" class="form-control value" id="motherPhoneNum" placeholder="请输入联系电话" />
				</div>
				<div class="params-item">
					<label class="control-label">检测结果：</label>
					<select type="text" class="form-control value" id="result">
						<option value=''>请选择状态</option>
						<option value="1">高风险</option>
						<option value="2">低风险</option>
						<option value="3">正常</option>
						<option value="4">异常</option>
					</select>
				</div>
			</div>
			<div class="params-warpper">
				<div class="params-item">
					<label class="control-label">送检医院：</label>
					<select id="search-customer" class="selectpicker form-control value" data-live-search="true" data-max-options="1">
					</select>
				</div>
				<div class="params-item">
					<label class="control-label">区/县：</label>
					<select name="search-country" id="search-country" class="form-control value"></select>
				</div>
				<div class="params-item">
					<label class="control-label">街道：</label>
					<select name="search-town" id="search-town" class="form-control value"></select>
				</div>
			</div>
			<div class="params-warpper">
				<div class="params-item">
					<label class="control-label">身份证号码：</label>
					<input type="text" placeholder="请输入身份证号码" class="form-control value" id="search-idcard" />
				</div>
				<div class="params-item">
					<label class="control-label">产品：</label>
					<select id="search-product" class="form-control value">
						<option value=''>请选择</option>
						<option value="DX0459">耳聋基因检测</option>
						<option value="DX0558">NIPT检测</option>
						<option value="DX0532">HPV检测</option>
						<option value="BS0001">产前血清学筛查</option>
						<option value="BS0002">新生儿疾病筛查</option>
						<option value="DX0016">地贫筛查</option>
					</select>
				</div>
				<div class="params-item" style="display: none">
					<label class="control-label">收费类型：</label>
					<select name="isCharge" id="isCharge" class="form-control value">
						<option value=''>请选择</option>
						<option value="1">免费</option>
						<option value="2">自费</option>
					</select>
				</div>
				<div class="params-item"></div>
			</div>
			<div class="params-warpper">
				<div class="params-item">
					<label class="control-label">扫码采样日期：</label>
					<input type="text" placeholder="开始日期" class="form-control value" id="search-scan-start-time" onblur="(this.type='text')"
						   onfocus="(this.type='date')" />
					<span class="split">~</span>
					<input type="text" placeholder="结束日期" class="form-control value" id="search-scan-end-time" onblur="(this.type='text')" onfocus="(this.type='date')"
					/>
				</div>
				<div class="params-item"></div>
			</div>
			<button class="btn btn-primary" id="search-btn" onclick="toSearch()">查询</button>
			<button class="btn btn-default" id="reset-btn" onclick="toRefresh()">重置</button>
		</div>
		<div style="display: flex;flex-direction: row; align-items: center;">
			<a href="javascript:void(0)" onclick="callParent('录入送检单','add-sample/add-sample.html')" class="btn btn-primary add-sample">录入送检单</a>
			<!--<a href="javascript:void(0);" onclick="pan()" class="btn btn-default">导出</a>-->
			<div id="fountainTextG">
				<div id="fountainTextG_1" class="fountainTextG">导</div>
				<div id="fountainTextG_2" class="fountainTextG">出</div>
				<div id="fountainTextG_3" class="fountainTextG">中</div>
				<div id="fountainTextG_4" class="fountainTextG">.</div>
				<div id="fountainTextG_5" class="fountainTextG">.</div>
				<div id="fountainTextG_6" class="fountainTextG">.</div>
				<div id="fountainTextG_7" class="fountainTextG">请</div>
				<div id="fountainTextG_8" class="fountainTextG">稍</div>
				<div id="fountainTextG_9" class="fountainTextG">后</div>
			</div>
		</div>
	</div>
	<div class="table-wrapper">

		<table id="sampleImport_mainTable" toolbar="#toolbar"></table>
	</div>
</div>

</div>

<a href="#top" id="goTop">
	<i class="fa fa-angle-up fa-3x"></i>
</a>


</body>
<script type="text/javascript">

	function callParent(title,url){

		window.parent.addTab(title,url);

    }
    var isLoadingAllData = true;//标识当前是不是在加载全部数据
    var isClickExportBtn = false;//标识当前是不是点击了导出按钮

    function getJsonFromUrl() {
        var query = location.search.substr(1);
        var result = {};
        query.split("&").forEach(function (part) {
            var item = part.split("=");
            result[item[0]] = decodeURIComponent(item[1]);
        });
        return result;
    }

    //总条目
    var total = 0;
    //总数据列表
    var dataList = null;
    var exportTimer = null;
    function handleLoading() {
        exportTimer && window.clearInterval(exportTimer)
        exportTimer = null
        exportTimer = setInterval(() => {
            if (window.sessionStorage.getItem('exportFinished')) {
            flag = false
            $("#fountainTextG").hide()
            window.sessionStorage.removeItem('exportFinished')
            exportTimer && window.clearInterval(exportTimer)
            exportTimer = null
            isClickExportBtn = false
        }
    }, 1000)
    }

	//区县列表
	$.ajax({
		method: 'POST',
		url: '/csfy/intf.do',
		data: { method: 'getAddrsToAccess', parentId: 4301 },
		success: function (res) {
			var options = '<option value="">请选择</option>'
			if (res && res.code == 200) {
				(res.rows || []).forEach(countryItem => {
					options += '<option value="' + countryItem.name + '">' + countryItem.name + '</option>';
				})
			}
			$('#search-country').html(options);
		}
	});

	$(function () {
		//街道
		$('#search-country').change(function () {
			var countryStr = $(this).val();//获得区县
			$.ajax({
				method: 'POST',
				url: '/csfy/intf.do',
				data: { method: 'getTownToUserAccess', name: countryStr },
				success: function (res) {
					var options = '<option value="">请选择</option>'
					if (res && res.code == 200) {
						(res.rows || []).forEach(countryItem => {
							options += '<option value="' + countryItem.name + '">' + countryItem.name + '</option>';
						})
					}
					$('#search-town').html(options);
				}
			});
		});
	});

	//医院列表
	$.ajax({
		method: 'POST',
		url: '/csfy/intf.do',
		data: {
			method: 'getCustomers',
			addressCity: '长沙市',
		},
		success: function (res) {
			if (res && res.code == 200) {
				var customerList = res.rows || [];
				var customerOptions = '<option value="">请选择医院</option>';
				customerList.forEach(customer => {
					customerOptions += '<option value="' + customer.customerCode + '">' + customer.customerName + '</option>';
				});
				$('#search-customer').html(customerOptions);
				//$("#search-customer option[value='34']").removeAttr("selected");//默认选中长沙市妇幼保健院
				$('.selectpicker').selectpicker('refresh');
			}
		}
	});

	var flag = false
	//判断
	function pan(){
        //判断要导出哪些数据
        var productCode = $("#search-product option:selected").text();//产品
        if(productCode==null||productCode==""||productCode=="请选择"){
            alert("请选择你要导出的产品");
        }else{
            exportTable();
        }
	}
	// 导出表格
	function exportTable() {

		var rows = $('#sampleImport_mainTable').datagrid('getSelections');
		if (rows.length > 0) {
			exportSampleExcel(rows)
		} else {
			if (flag) {
				return false
			}
			flag = true
			isClickExportBtn = true
			$("#fountainTextG").show()
			if (dataList && dataList.length && dataList.length == total) {
				setTimeout(() => {
					exportSampleExcel(dataList)
				}, 0)
				handleLoading()
				return false
			}
			if(!isLoadingAllData){
				$.ajax({
					method: 'POST',
					url: '/csfy/intf.do?method=getExportSampleBases?exportMark=true',
					data:getQueryParams(),
					success: function (res) {
						if (res && res.code && res.code == 200) {
							dataList = res.rows
							setTimeout(() => {
								exportSampleExcel(dataList)
							}, 0)
							handleLoading()
						} else {
							flag = false
							$("#fountainTextG").hide()
							isClickExportBtn = false
						}
					},
					error: function (err) {
						flag = false
						$("#fountainTextG").hide()
						isClickExportBtn = false
					}
				})
			}
		}
	}

	//导出表格By邱沙沙 5/8
	function exportSampleBases(){

		var dataE= getEportQueryParams();
		var a = '/csfy/intf.do?method=export'+dataE;
		//判断要导出哪些数据
		var productCode = $("#search-product option:selected").text();//产品
		if(productCode==null||productCode==""||productCode=="请选择"){
			alert("请选择你要导出的产品");
		}else{
			location.href=a;
		}

	}


	$(".maincontent").height($("body").height() - 50);
	//获取搜索条件
	function getQueryParams() {

		var sampleName = $("#sampleName").val();//姓名
		var motherPhoneNum = $("#motherPhoneNum").val();//联系电话
		var searchResult = $("#result").val();//检测结果
		var customerCode = $("#search-customer").val();//送检医院
		var country = $("#search-country").val();//区县
		var town = $("#search-town").val();//街道
		var idCard = $("#search-idcard").val();//身份证号码
		var productCode = $("#search-product").val();//产品
		var scanStartTime = $("#search-scan-start-time").val();//开始扫码采样日期
		var scanEndTime = $("#search-scan-end-time").val();//结束扫码采样日期
		var isCharge = $("#isCharge").val();//收费类型

		var params = {};
		if (sampleName) {
			params.sampleName = sampleName;
		}
		if (motherPhoneNum) {
			params.motherPhoneNum = motherPhoneNum;
		}
		if (searchResult) {
			params.searchResult = searchResult;
		}
		if (customerCode) {
			params.customerCode = customerCode;
		}
		if (country) {
			params.addressCounty = country;
		}
		if (town) {
			params.addressTown = town;
		}
		if (idCard) {
			params.idCard = idCard;
		}
		if (productCode) {
			params.productCode = productCode;
		}
		if (scanStartTime) {
			params.useStartTime = scanStartTime;
		}
		if (scanEndTime) {
			params.useEndTime = scanEndTime;
		}
		if(isCharge){
			params.isCharge = $("#isCharge").val();
		}
		return params;
	}
	function Trim(str)
	{
		return str.replace(/(^\s*)|(\s*$)/g, "");
	}
	//获取导出搜索条件
	function getEportQueryParams() {
		var sampleName = $("#sampleName").val();//姓名
		var motherPhoneNum = $("#motherPhoneNum").val();//联系电话
		var searchResult = $("#result").val();//检测结果
		var customerCode = $("#search-customer").val();//送检医院
		var country = $("#search-country").val();//区县
		var town = $("#search-town").val();//街道
		var idCard = $("#search-idcard").val();//身份证号码
		var productCode = $("#search-product").val();//产品
		var scanStartTime = $("#search-scan-start-time").val();//开始扫码采样日期
		var scanEndTime = $("#search-scan-end-time").val();//结束扫码采样日期
		var data ="";
		if (sampleName!=null&&sampleName!="") {
			data+="&sampleName="+sampleName;
		}
		if (motherPhoneNum!=null&&motherPhoneNum!="") {
			data+="&motherPhoneNum="+motherPhoneNum;
		}

		if (searchResult!=null&&searchResult!="") {
			data+="&searchResult="+searchResult;
		}
		if (customerCode!=null&&customerCode!="") {
			data+="&customerCode="+customerCode;
		}

		if (country!=null&&country!="") {
			data+="&country="+country;
		}
		if (town!=null&&town!="") {
			data+="&town="+town;
		}

		if (idCard!=null&&idCard!="") {
			data+="&idCard="+idCard;
		}
		if (productCode!=null&&productCode!="") {
			data+="&productCode="+productCode;
		}
		if (scanStartTime!=null&&scanStartTime!="") {
			data+="&scanStartTime="+scanStartTime;
		}
		if (scanEndTime!=null&&scanEndTime!="") {
			data+="&scanEndTime="+scanEndTime;
		}
		var b= data.trim();
		return b;
	}
	function show(){
		var sampleName = $("#sampleName").val();//姓名
		var motherPhoneNum = $("#motherPhoneNum").val();//联系电话
		var searchResult = $("#result option:selected").text();//检测结果$(“#test option:selected”)
		var customerCode = $("#search-customer option:selected").text();//送检医院
		var country = $("#search-country option:selected").text();//区县
		var town = $("#search-town option:selected").text();//街道
		var idCard = $("#search-idcard").val();//身份证号码
		var productCode = $("#search-product option:selected").text();//产品
		var scanStartTime = $("#search-scan-start-time").val();//开始扫码采样日期
		var scanEndTime = $("#search-scan-end-time").val();//结束扫码采样日期
		var data ="";
		if (sampleName!=null&&sampleName!="") {
			data+=" 姓名为"+sampleName;
		}
		if (motherPhoneNum!=null&&motherPhoneNum!="") {
			data+=" 联系电话为"+motherPhoneNum;
		}

		if (searchResult!=null&&searchResult!=""&&searchResult!='请选择状态') {
			data+=" 检测结果为"+searchResult;
		}
		if (customerCode!=null&&customerCode!=""&&customerCode!='请选择医院') {
			data+=" 送检医院为"+customerCode;
		}

		if (country!=null&&country!="") {
			data+=" 区/县为"+country;
		}
		if (town!=null&&town!="") {
			data+=" 街道为"+town;
		}

		if (idCard!=null&&idCard!="") {
			data+=" 身份证号码为"+idCard;
		}
		if (productCode!=null&&productCode!="") {
			data+=" 产品为"+productCode;
		}
		if (scanStartTime!=null&&scanStartTime!="") {
			data+=" 扫码采样开始日期为"+scanStartTime;
		}
		if (scanEndTime!=null&&scanEndTime!="") {
			data+=" 扫码采样结束日期为"+scanEndTime;
		}
		return data;

	}
	//重置刷新
	function toRefresh() {
		$("#sampleName").val('');//姓名
		$("#motherPhoneNum").val('');//联系电话
		$("#result").val('');//检测结果
		$("#search-customer").val('');//送检医院
		$("#search-country").val('');//区县
		$("#search-steet").val('');//街道
		$("#search-idcard").val('');//身份证号码
		$("#search-product").val('');//产品
		$("#search-scan-start-time").val('');//开始扫码采样日期
		$("#search-scan-end-time").val('');//结束扫码采样日期
		$("#sampleImport_mainTable").datagrid("reload", {});
	}
	//按条件搜索
	function toSearch() {
		$('#sampleImport_mainTable').datagrid('reload', getQueryParams());
	}
	//退出登录
	function logout() {
		$.ajax({
			url: '/csfy/dologout.do',
			method: 'POST',
			success: function (res) {
				if (JSON.parse(res).code == 200) {
					window.location.href = "/csfy/index.do"
				}
			}
		})
	}
	//获取当前登录用户信息
	$(document).ready(function () {
		$.ajax({
			method: 'POST',
			url: '/csfy/intf.do',
			data: { method: 'getLoginUserInfo' },
			success: res => {
				if (res.code == 10086) {
					alert("请重新登录！");
				} else {
					if (res.code == 200) {
						$(".username").html(res.rows.userName);
					}
				}
			}
		})
	})

	function showStatus(value, row) {
		if (value == 1) {
			value = "已采样";
		} else {
			value = '';
		}
		return value;
	}

	function showText(value, row) {
		var step = row.step;
		if (step != null && step != '') {
			if (step.indexOf("1") == 3 && (value == null || value == '')) {
				value = "请查看报告！";
			} else if (step.indexOf("1") != 3 && value != null && value != '') {
				value = '';
			}
		}
		return value;
	}

	function changeStatus(value, row) {
		// 0未确认，1已确认
		if (value == "0") {
			value = "<image src='resources/images/icons/yes.png'/>";
		}
		if (value == "1") {
			value = "<image src='resources/images/icons/stop.png'/>";
		}
		return value;
	}

	function changeExpressStatus(value, row) {
		// 0 否 1是
		if (value == "0") {
			return "否";
		}
		if (value == "1") {
			return "是";
		}
		return value;
	}

	function changeIDCard(value, row) {
		if (row.idCardType == '0') {
			return value;
		} else {
			return '';
		}
	}

	function changeSys(value, row) {
		if (value == "0") {
			return "本系统";
		}
		if (value == "01") {
			return "SIMS推送";
		}
		return value;
	}

	function showTemplate(value, row) {
		if (value == '1') return '有';
		if (value == '0') return '无';
		return value;
	}
    //详情页面的跳转方法
    function toDetail(obj) {

        var sampleId=obj[0];
        var productCode=obj[1];
        var idCard=obj[2];
        var rowJson = '';
        $.ajax({
            method: 'POST',
            async:false,
            url: '/csfy/intf.do?method=getExportSampleBases&sampleBaseId='+ sampleId +'&productCode='+ productCode+'&idCard='+idCard,
            success: function (res) {
                console.log(res.rows);
                if (res && res.code && res.code == 200 && res.rows ) {
                    rowJson = JSON.stringify(res.rows).replace(/\[/g,'').replace(/\]/g,'');
                }
            }
        });
        var row = JSON.parse(rowJson);
        if (row) {
            var file;
            if (row.fileVer == 'temp/deaf.jsp') {
                file = 'deaf_detail.jsp';
            } else if (row.fileVer == 'temp/diping.jsp') {
                //file = 'dipin_detail.jsp';
            } else if (row.fileVer == 'temp/akxChildGenTest.jsp') {
                file = 'akxChildGenTest_detail.jsp';
            } else if (row.fileVer == 'temp/HPV.jsp') {
                //file = 'HPV_detail.jsp';
            } else if (row.fileVer == 'temp/Nifty.jsp') {
                file = 'nifty_detail.jsp';
            } else if (row.fileVer == 'temp/sample1.jsp') {
                //file = 'sample1.html';
            } else if (row.fileVer == 'temp/sample2.jsp') {
                //file = 'sample2.html';
            }
            if (file) {
                sessionStorage.setItem("sampleInfos", JSON.stringify(row));
				if(row.sampleName == undefined){
					//新生儿送检单查看
					callParent(row.motherName + '送检单', "add-sample/" + file);
				}else {
					callParent(row.sampleName + '送检单', "add-sample/" + file);
				}
            }else{
                alert("暂不支持此种送检单！");
            }
        }
    }
    //编辑页面的跳转方法
    function toUpdate(obj) {
        var sampleId=obj[0];
        var productCode=obj[1];
        var idCard=obj[2];

        var rowJson = '';
        $.ajax({
            method: 'POST',
            async:false,
            url: '/csfy/intf.do?method=getExportSampleBases&sampleBaseId='+ sampleId +'&productCode='+ productCode+'&idCard='+idCard,
            success: function (res) {
                console.log(res);
                if (res && res.code && res.code == 200 && res.rows ) {
                    rowJson = JSON.stringify(res.rows).replace(/\[/g,'').replace(/\]/g,'');
                }
            }
        });

        var row = JSON.parse(rowJson);
		if (row) {
			var file;
			if (row.fileVer == 'temp/deaf.jsp') {
				file = 'deaf.jsp';
			} else if (row.fileVer == 'temp/diping.jsp') {
				file = 'dipin.jsp';
			} else if (row.fileVer == 'temp/akxChildGenTest.jsp') {
				file = 'akxChildGenTest.jsp';
			} else if (row.fileVer == 'temp/HPV.jsp') {
				file = 'HPV.jsp';
			} else if (row.fileVer == 'temp/Nifty.jsp') {
				file = 'nifty.jsp';
			} else if (row.fileVer == 'temp/sample1.jsp') {
				file = 'sample1.html';
			} else if (row.fileVer == 'temp/sample2.jsp') {
				file = 'sample2.html';
			}
			if (file) {
				sessionStorage.setItem("sampleInfos", JSON.stringify(row));
                    callParent2('编辑送检单详情','add-sample/add-sample.html?file=' + file + '&edit=true');

			}
		}
	}

    //删除页面未采样数据记录
    function toDelete(sampleId){
        var isDelete = confirm("您确定要删除这条送检单吗？删除后将无法恢复，请谨慎操作！");

        if(isDelete == true){

            $.ajax({
                method: 'POST',
                async:false,
                url: '/csfy/intf.do?method=deleteExportSampleBases&sampleBaseId='+ sampleId ,
                success: function (res) {
                    console.log(res);
                    if (res && res.code && res.code == 200) {
                        alert("删除成功！");
                        refreshParent('删除送检单','/csfy/static/manage-sys/sample-list.html');
                    }
                }
            })
        }
        else{
            alert("已取消");
            return false;
        }
    }


    //操作功能判断
    var params = getJsonFromUrl().operate;
    function showEdit(value, row) {
        var str = "";
       if (row.sampleStatus != 1) {

           if(params == "edit"){
               str = '<a class="sample-edit" href="javascript:toUpdate([' + JSON.stringify(row.sampleBaseId).replace(/\"/g,"'")+','+JSON.stringify(row.productCode).replace(/\"/g,"'") +','+ JSON.stringify(row.idCard).replace(/\"/g,"'")+ '])" style="color:#337ab7;margin-right:10px;">编辑</a>';
		   }else if(params == "delete"){
               str =  '<a class="sample-edit" href="javascript:toDelete(' + JSON.stringify(row.sampleBaseId).replace(/\"/g,"'")+')" style="color:#337ab7">删除</a>';
		   }
        }else if(params == "show"){
           str = '<a class="sample-edit" href="javascript:toDetail([' + JSON.stringify(row.sampleBaseId).replace(/\"/g,"'")+','+JSON.stringify(row.productCode).replace(/\"/g,"'") +','+ JSON.stringify(row.idCard).replace(/\"/g,"'")+ '])" style="color:#337ab7;margin-right:10px;">查看</a>';
	   }
        return str;
    }

	function formatCardId(value, row) {
		var cardId = row.idCard + '-';
		return cardId
	}

    $('#sampleImport_mainTable').datagrid({
        url: '/csfy/intf.do?method=getExportSampleBases',
        fit: true,
        rownumbers: true,
        pagination: true,
        singleSelect: false,
        striped: true,
        fitColumns: false,
        frozenColumns:
            [[
                { field: 'ck', checkbox: 'true' }
            ]],
        columns: [[
            { field: 'sampleInfoId', hidden: true },
            { field: 'sampleNum', hidden: true },
            { field: 'sampleName', title: '姓名', width: 120, align: 'center' },
            { field: 'editAttribute', title: '操作', width: 90, align: 'center', formatter: showEdit },
            // { field: 'customerCode', title: '客户编码', width: 250, align: 'center' },
            { field: 'customerName', title: '送检单位', width: 170, align: 'center' },
            { field: 'sampleStatus', title: '样品状态', width: 100, align: 'center', formatter: showStatus },
            //{ field: 'result', title: '检测结果', width: 150, align: 'center', formatter: showText },
            //{ field: 'motherPhoneNum', title: '联系电话', width: 100, align: 'center' },
            // { field: 'status', title: '停测状态', width: 80, align: 'center', formatter: changeStatus },
            // { field: 'isUrgent', title: '是否加急', width: 60, align: 'center', formatter: changeExpressStatus },
            // { field: 'productCode', title: '产品编码', width: 120, align: 'center' },
            { field: 'couponNum', title: '免费券编码', width: 120, align: 'center' },
            { field: 'productName', title: '产品名称', width: 150, align: 'center' },
            { field: 'idCard', title: '身份证号', width: 150, align: 'center', formatter: formatCardId },//, formatter: changeIDCard
            { field: 'transfusionDate', title: '扫码采样时间', width: 120, align: 'center' },
//            { field: 'usedTime', title: '扫码时间', width: 120, align: 'center' },
            //addressCountry

            { field: 'addressCounty', title: '区/县', width: 120, align: 'center' },
            { field: 'addressTown', title: '街道', width: 120, align: 'center' },
            { field: 'sampleAge', title: '年龄', width: 50, align: 'center' },
            { field: 'familyAddress', title: '常住地址', width: 200, align: 'center' },
//            { field: 'address', title: '联系地址', width: 250, align: 'center' },

            // { field: 'projectName', title: '项目名称', width: 300, align: 'center' },
            // { field: 'productLine', title: '产品线', width: 100, align: 'center' },
            // { field: 'productDirection', title: '产品方向', width: 100, align: 'center' },
            //bloodDate

            // { field: 'logisticsTime', title: '物流寄送时间', width: 120, align: 'center' },
            // { field: 'receivedTime', title: '样品接收时间', width: 120, align: 'center' },
            // { field: 'productTime', title: '基因检测时间', width: 120, align: 'center' },
            // { field: 'reportTime', title: '报告时间', width: 120, align: 'center' },
            //{ field: 'createUser', title: '录入人', width: 200, align: 'center' },
            { field: 'createTime', title: '录入时间', width: 120, align: 'center' },
            { field: 'lastModifiedUser', title: '最后修改人', width: 200, align: 'center' },
            { field: 'lastModifiedTime', title: '最后修改时间', width: 120, align: 'center' },
            // { field: 'connectSystem', title: '来源系统', width: 100, align: 'center', formatter: changeSys }, --%>
            // { field: 'hasTemplate', title: '是否有模板', width: 100, align: 'center', formatter: showTemplate }
        ]],
        onLoadSuccess: function (data) {
            total = data.total
        }
    });

    //添加tab
    function callParent(title,url) {
        //如果存在，直接刷新页面
        if (parent.$('#tt').tabs('exists', title)) {
            parent.$('#tt').tabs('close', title);
            window.parent.addTab(title, url);
        } else {
            window.parent.addTab(title, url);
        }
    }

    //刷新当前tab
    function refreshParent(title,url) {
        //删除成功后直接刷新页面
        if (parent.$('#tt').tabs('exists', title)) {
            var currTab = parent.$('#tt').tabs('getTab', title);
            var content = '<iframe scrolling="auto" id ="' + url + '" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
            parent.$('#tt').tabs('update',
                {
                    tab: currTab,
                    options: {
                        content: content,
                        closable: true
                    }
                });
        }
    }

    //跳转到上级tab
    function callParent2(title,url) {
        //如果存在，直接刷新页面
        if (parent.$('#tt').tabs('exists', title)) {
            parent.$('#tt').tabs('close', title);
            window.parent.addTab(title, url);
        } else {
            window.parent.addTab(title, url);
        }
    }

</script>

<!-- 要导出的送检单table模板 -->
<script id="table" type="text/html">
	<table border="1" class="tables">
		<tr>
			{{each ths item i}}
			<th>{{item.fieldValue}}</th>
			{{/each}}
		</tr>
		{{each trs item i}}
		<tr>
			{{each item value i}}
			<td>{{value}}</td>
			{{/each}}
		</tr>
		{{/each}}
	</table>


	}


</script>


</html>